import {Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn,} from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';
import {BaseEntity} from "../../../../common/entities/base";
import {ProfessionalEntity} from "./professional.entity";
import {SchoolEntity} from "../../school/entities/school.entity";

@Entity('edu_professional_school', {
  comment: '专业与学校关联表',
})
export class ProfessionalSchoolEntity extends  BaseEntity{
  @PrimaryGeneratedColumn({ type: 'int', name: 'id', comment: '主键ID' })
  public id: number;

  @ApiProperty({ description: '专业ID' })
  @Column({ type: 'int', name: 'pro_id', comment: '专业ID' })
  public proId: number;

  @ApiProperty({ description: '学校ID' })
  @Column({ type: 'int', name: 'school_id', comment: '学校ID' })
  public schoolId: number;

  @ApiProperty({ description: '开设年份' })
  @Column({ type: 'varchar', name: 'start_year', default:null, comment: '开设年份' })
  public startDate: string;

  @ManyToOne(() => SchoolEntity, school => school.schoolId)
  @JoinColumn({ name: 'school_id' })
  public school: SchoolEntity;

  @ManyToOne(() => ProfessionalEntity, professional => professional.proId)
  @JoinColumn({ name: 'pro_id' })
  public professional: ProfessionalEntity;

}
